<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>后台管理</title>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" href="<?php echo $this->getWebSkinPath()."css/admin.css";?>" />
	<meta name="robots" content="noindex,nofollow">
	<link rel="shortcut icon" href="<?php echo IUrl::creatUrl("")."favicon.ico";?>" />
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/jquery/jquery-1.12.4.min.js"></script>
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artdialog/artDialog.js"></script><script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artdialog/plugins/iframeTools.js"></script><link rel="stylesheet" type="text/css" href="/git/micarshop/runtime/_systemjs/artdialog/skins/aero.css" />
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/form/form.js"></script>
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/autovalidate/validate.js"></script><link rel="stylesheet" type="text/css" href="/git/micarshop/runtime/_systemjs/autovalidate/style.css" />
	<script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artTemplate/artTemplate.js"></script><script type="text/javascript" charset="UTF-8" src="/git/micarshop/runtime/_systemjs/artTemplate/artTemplate-plugin.js"></script>
	<script type='text/javascript' src="<?php echo $this->getWebViewPath()."javascript/common.js";?>"></script>
	<script type='text/javascript' src="<?php echo $this->getWebViewPath()."javascript/admin.js";?>"></script>
</head>
<body>
	<div class="container">
		<div id="header">
			<div class="logo">
				<a href="<?php echo IUrl::creatUrl("/system/default");?>"><img src="<?php echo $this->getWebSkinPath()."images/admin/logo.png";?>" width="303" height="43" /></a>
			</div>
			<div id="menu">
				<ul name="topMenu">
					<?php $menuData=menu::init($this->admin['role_id']);?>
					<?php foreach(menu::getTopMenu($menuData) as $key => $item){?>
					<li>
						<a hidefocus="true" href="<?php echo IUrl::creatUrl("".$item."");?>"><?php echo isset($key)?$key:"";?></a>
					</li>
					<?php }?>
				</ul>
			</div>
			<p><a href="<?php echo IUrl::creatUrl("/systemadmin/logout");?>">退出管理</a> <a href="<?php echo IUrl::creatUrl("/system/admin_repwd");?>">修改密码</a> <a href="<?php echo IUrl::creatUrl("/system/default");?>">后台首页</a> <a href="<?php echo IUrl::creatUrl("");?>" target='_blank'>商城首页</a> <span>您好 <label class='bold'><?php echo isset($this->admin['admin_name'])?$this->admin['admin_name']:"";?></label>，当前身份 <label class='bold'><?php echo isset($this->admin['admin_role_name'])?$this->admin['admin_role_name']:"";?></label></span></p>
		</div>
		<div id="info_bar">
			<label class="navindex"><a href="<?php echo IUrl::creatUrl("/system/navigation");?>">快速导航管理</a></label>
			<span class="nav_sec">
			<?php $query = new IQuery("quick_naviga");$query->where = "admin_id = {$this->admin['admin_id']} and is_del = 0";$items = $query->find(); foreach($items as $key => $item){?>
			<a href="<?php echo isset($item['url'])?$item['url']:"";?>" class="selected"><?php echo isset($item['naviga_name'])?$item['naviga_name']:"";?></a>
			<?php }?>
			</span>
		</div>

		<div id="admin_left">
			<ul class="submenu">
				<?php $leftMenu=menu::get($menuData,IWeb::$app->getController()->getId().'/'.IWeb::$app->getController()->getAction()->getId())?>
				<?php foreach(current($leftMenu) as $key => $item){?>
				<li>
					<span><?php echo isset($key)?$key:"";?></span>
					<ul name="leftMenu">
						<?php foreach($item as $leftKey => $leftValue){?>
						<li><a href="<?php echo IUrl::creatUrl("".$leftKey."");?>"><?php echo isset($leftValue)?$leftValue:"";?></a></li>
						<?php }?>
					</ul>
				</li>
				<?php }?>
			</ul>
			<div id="copyright"></div>
		</div>

		<div id="admin_right">
			<div class="headbar">
	<div class="position"><span>系统</span><span>></span><span>板块信息</span><span>></span><span><?php if(isset($this->bankuaiRow['plate_id'])){?>编辑<?php }else{?>添加<?php }?>板块</span></div>
</div>
<div class="content_box">
	<div class="content form_content">
		<form action="<?php echo IUrl::creatUrl("/system/bankuai_edit_act");?>"  method="post" name="bankuai_edit" id="commit" >
			<input type='hidden' name='id' value="<?php echo isset($this->bankuaiRow['plate_id'])?$this->bankuaiRow['plate_id']:"";?>" />
			<table class="form_table">
				<col width="150px" />
				<col />
				<tr>
					<th>板块名：</th>
					<td>
						<input type='text' value="<?php if(isset($this->bankuaiRow['plate_name'])){?> <?php echo isset($this->bankuaiRow['plate_name'])?$this->bankuaiRow['plate_name']:"";?><?php }else{?><?php }?>"   name='plate_name' class='normal'  onblur="checkName();" />
						<label id='unique'>* 板块的名称，请填写英文字母，数字或下划线，在4-20个字符之间</label>
					</td>
				</tr>
				
				<tr>
					<th>二级域名：</th>
					<td>
						<input type='text' value="<?php if(isset($this->bankuaiRow['plate_domainName'])){?> <?php echo isset($this->bankuaiRow['plate_domainName'])?$this->bankuaiRow['plate_domainName']:"";?><?php }else{?><?php }?>" name='plate_domainName' class='normal'  onblur="checkName();" />
						<label id='unique'>* 二级域名，请填写英文字母，数字或下划线，在4-20个字符之间</label>
					</td>
				</tr>
				
				<tr>
					<th>描述：</th>
					<td>
						<textarea rows="10" cols="10" name="plate_describe"  ><?php if(isset($this->bankuaiRow['plate_describe'])){?> <?php echo isset($this->bankuaiRow['plate_describe'])?$this->bankuaiRow['plate_describe']:"";?><?php }else{?><?php }?></textarea>
						<label id='unique'>　板块的描述</label>
					</td>
				</tr>
				
				<tr>
					<th>是否显示：</th>
					<td>
						<select name="plate_isshow"  style="padding: 3px 3px 2px 3px;border: 1px solid #elelel;color:#7a7a7a;">
							<option>1</option>
							<option>0</option>
						</select>
						<label id='unique'>　0为不显示，1位显示。默认为显示</label>
					</td>
				</tr>
				<tr><td></td><td><div style="width: 50px;line-height: 160%;text-align: center;" class="submit" onclick="return checkCommit()"><span>保 存</span></div></td></tr>
			</table>
		</form>
	</div>
</div>

<script type='text/javascript'>



//ajax检查板块名唯一性
function checkName()
{
	
	var nameVal = $('[name="plate_name"]').val(); //板块名
	var idVal   = $('[name="id"]').val();         //板块id
	
	if(nameVal == ''){
		$('[name="bankuai_name"]').removeClass('valid-text');
		$('#unique').removeClass('valid-msg');

		$('[name="bankuai_name"]').addClass('invalid-text');
		$('#unique').addClass('invalid-msg');
		$('#unique').html('板块的名称，请填写英文字母，数字或下划线，在4-20个字符之间');
		return ;
		//$('#unique').html(nameVal+'已经存在，请重新更换一个');
	}
		
	//alert(idVal);
	jQuery.post(
		'<?php echo IUrl::creatUrl("/system/check_bankuaiName");?>',{bankuai_name:nameVal,bankuai_id:idVal},function(content)
		{
			var content = $.trim(content);
			
			if(content == -1)
			{
				
				$('[name="bankuai_name"]').removeClass('valid-text');
				$('#unique').removeClass('valid-msg');

				$('[name="bankuai_name"]').addClass('invalid-text');
				$('#unique').addClass('invalid-msg');

				$('#unique').html(nameVal+'已经存在，请重新更换一个');
			}else{
				$('#unique').html('板块的名称，请填写英文字母，数字或下划线，在4-20个字符之间');
				$('#unique').removeClass('invalid-msg');
				$('[name="bankuai_name"]').removeClass('invalid-text');
				
				$('#unique').addClass('valid-msg');
				$('[name="bankuai_name"]').addClass('valid-text');
			}
		}
	);
}

//提交检查
function checkCommit(){
	
	var nameVal = $('[name="plate_name"]').val(); //板块名
	var idVal   = $('[name="id"]').val();         //板块id
	
	if(nameVal == ""){
		alert("请填写板块名");
		console.log("请填写板块名");
		return false;
	}
	
	/*
	jQuery.post(
		'<?php echo IUrl::creatUrl("/system/check_bankuaiName");?>',{bankuai_name:nameVal,bankuai_id:idVal},function(content){
			var content = $.trim(content);
			
			if(content == -1){
				alert("板块名存在，请重新填写");
				console.log("板块名存在，请重新填写");
				return false;
			}
			console.log("ok");
			alert('ok')
		}
	);*/
	
	$.ajax({  
        type : "post",  
         url : "system/check_bankuaiName",  
         data : "bankuai_name=" + nameVal+"&bankuai_id="+idVal,
         async : false,  
         success : function(data){  
        	//alert(data);
         	if(data == -1){
         		alert("板块名存在");
         		return false;
         	}else{
         		
         		$("#commit").submit();
         		return true;
         	}
         }  
    }); 
	
	//return true;
}

</script>














		</div>
	</div>

	<script type='text/javascript'>
	//隔行换色
	$(".list_table tr:nth-child(even)").addClass('even');
	$(".list_table tr").hover(
		function () {
			$(this).addClass("sel");
		},
		function () {
			$(this).removeClass("sel");
		}
	);

	//按钮高亮
	var topItem  = "<?php echo key($leftMenu);?>";
	$("ul[name='topMenu']>li:contains('"+topItem+"')").addClass("selected");

	var leftItem = "<?php echo IUrl::getUri();?>";
	$("ul[name='leftMenu']>li a[href^='"+leftItem+"']").parent().addClass("selected");
	</script>
</body>
</html>
